package bancosys.tec.security.chinesewall;


/**
 * Classe que armazena o {@link ChineseWallContext} associado à thread.
 *
 * @author Marco
 */
public final class ChineseWallContextHolder {

    /**
     * ThreadLocal que armazena o contexto de chinese wall.
     */
    private static ThreadLocal<ChineseWallContext> chineseWallContexts = new ThreadLocal<ChineseWallContext>();

    /**
     * Construtor.
     */
    private ChineseWallContextHolder() {
        // vazio
    }

    /**
     * Retorna o contexto de chinese wall associado à thread.
     * @return o contexto de chinese wall associado à thread.
     */
    public static ChineseWallContext get() {
        return chineseWallContexts.get();
    }

    /**
     * Associa um contexto de chinese wall à thread.
     * @param chineseWallContext contexto de chinese wall que será associado à thread.
     */
    public static void set(ChineseWallContext chineseWallContext) {
        chineseWallContexts.set(chineseWallContext);
    }

    /**
     * Remove o contexto de chinese wall.
     */
    public static void clear() {
        chineseWallContexts.set(null);
    }
}
